<form action='index.php?input&action=inputProvider'	method='post' enctype='multipart/form-data' id='frmInputProvider'>
	<input type="hidden" name="latitude" value="<?php echo $latitude?>"/>
	<input type="hidden" name="longitude" value="<?php echo $longitude?>"/>
	<fieldset class="frm">
    	<ol>
        	<li class="input">
            	<label for="name">Tên Địa Điểm</label>
                <input type="text" class="txt_full" name="txtProviderName" />
            </li>
            <li class="input">
            	<label for="mota">Mô Tả</label>
                <br />
                <textarea id="diadiem_input" class="textarea_input" rows="5" cols="60" name="txtProviderDes"></textarea>				
			</li>
            <li class="input">
            	<label for="thanhpho">Thành phố</label>
				<select class="txt_full" id="comboCity" name="selCity">  
					<option value="">234</option>
				<?php
					foreach ($arrLocationCity as $location) {
				?>
						<option value="<?php echo $location->getLocationID()?>"><?php echo $location->getName()?></option>
				<?php 
					} 
				?>                                  	
                </select>
            </li>
            <li class="input">
            	<label for="quan">Quận/Huyện</label>
                <select class="txt_full" id="comboDistrict" name="selDistrict">
                	<option value=""></option>
                <?php
					foreach ($arrLocationDistrict as $location) {
						
				?>
						<option value="<?php echo $location->getLocationID()?>"><?php echo $location->getName()?></option>
				<?php 
					} 
				?>
                </select>
			</li>
            <li class="input">
            	<label for="phuong">Phường/Xã</label>
                <select class="txt_full" id="comboWard" name="selWard">
                	<option value=""></option>
                <?php
					foreach ($arrLocationWard as $location) {
				?>
						<option value="<?php echo $location->getLocationID()?>"><?php echo $location->getName()?></option>
				<?php 
					} 
				?>
                </select>
			</li>        
            <li class="input">  
            	<label for="sonha">Số Nhà</label>
                <input type="text" class="txt_short" name="txtNumber" />
            </li>
            <li class="input">        
            	<label for="duong">Đường</label>
				<input type="text" class="txt_full" name="txtStreet" />
            </li>      
            <li class="input">        
            	<label for="website">Website</label>
				<input type="text" class="txt_full" name="txtWebsite" />
            </li>
            <li class="input">
            	<label for="cellphone">ĐT di động</label>
                <input type="text" class="txt_full" name="txtCellphone" />
            </li>
            <li class="input">
            	<label for="telephone">ĐT cố định</label>
                <input type="text" class="txt_full" name="txtTelephone" />
            </li>                                                          
            <li class="input">
            	<label for="hinhanh">Hình Ảnh</label>
				<input type="file" name="imgProvider" id="imgProvider" />
            </li>  
            <li>
            	<label for="phanloai">Phân Loại</label>
            	<input type="hidden" name="categoryProviderList" />
                <div style="display:inline-block">
                	<table id="tblCatProvider">
                    	<tr>
                        	<td>
                                <select name="selCatProvider1" id="selCatProvider1">
                                	<?php
                                		$catProvider =  $arrCatProvider1[0];
                                	?>
                                	<option selected="selected" value="<?php echo $catProvider->getCategoryID();?>"><?php echo $catProvider->getCategory();?></option>
                                	<?php                 
                                	    for ($i = 1; $i < count($arrCatProvider1); $i++) {
                                			$catProvider = $arrCatProvider1[$i];                                	
                                	?>
                                	<option value="<?php echo $catProvider->getCategoryID();?>"><?php echo $catProvider->getCategory();?></option>
                                	<?php 		
                                		} 
                                	?>	
                                </select>
                            </td>
                            <td>
                                <select name="selCatProvider2" id="selCatProvider2">
                                    <?php
                                		$catProvider =  $arrCatProvider2[0];
                                	?>
                                	<option selected="selected" value="<?php echo $catProvider->getCategoryID();?>"><?php echo $catProvider->getCategory();?></option>
                                	<?php                 
                                	    for ($i = 1; $i < count($arrCatProvider2); $i++) {
                                			$catProvider = $arrCatProvider2[$i];                                	
                                	?>
                                	<option value="<?php echo $catProvider->getCategoryID();?>"><?php echo $catProvider->getCategory();?></option>
                                	<?php 		
                                		} 
                                	?>                            	
	                            </select>
                            </td>
                            <td><input type="button" id="lnkAddProviderCategory" value="Thêm" /></td>                            
						</tr>                                		                                		
					</table>
	            </div>
    		</li>   
            <li class="input">
            	<label for="danhgia">Đánh Giá</label>                                    
                <div style="display:inline-block;" id='blockDanhGia'>
                </div>                                                                        
            </li>  					                                                                    
		</ol>
	</fieldset>
    <div class="searchBt"><input type="submit" value="Xong Rùi" /></div>
</form>
<div class="clear"></div>

<script language="javascript">
	$('#comboCity').val(<?php echo $city?>);
	$('#comboDistrict').val(<?php echo $district?>);
	$('#comboWard').val(<?php echo $ward?>);
	$('input[name=txtStreet]').val('<?php echo $street?>');

	$('#lnkAddProviderCategory').click(function() {				
		var val = $('#selCatProvider2 option:selected').val();
		var newRow = '<tr><td>' + $('#selCatProvider1 option:selected').html() + '</td>' 
			+ '<td>' + $('#selCatProvider2 option:selected').html() + '</td>' 
			+ '<td>' + '<input type="button" value="Xóa" onclick="$.removeRow(this)"></td>'
			+ '<td><input type="hidden" class="hiddenCatProviderID" value="' + val + '" /></td>' 
			+'</tr>';
		$('#tblCatProvider tr:last').after(newRow);
	});	
	
	$('#frmInputProvider').submit(function() {
		var str = '';
		if ($('#frmInputProvider [name=txtProviderName]').val() == '') {			
			str += 'Bạn chưa nhập tên provider\n';
		}
		if ($('#frmInputProvider [name=txtNumber]').val() == '') {
			str += 'Bạn chưa nhập số nhà\n';
		}
		if ($('#frmInputProvider [name=txtStreet]').val() == '') {
			str += 'Bạn chưa nhập số nhà\n';
		}	
		if ($('#imgProvider').val() == '') {
			str += 'Bạn chưa upload hình ảnh\n';			
		} 

		if (str != '') {
			alert(str);
			return false;
		}	

		var str = '';
		$('input[class=hiddenCatProviderID]').each(function(index) {
			str += ' ' + $(this).val();		    
		});		
		$('input[name=categoryProviderList][type=hidden]').val(str);
		
		return true;
	});

	$('#selCatProvider1').change(function() {
		pid = $('#selCatProvider1 option:selected').val();
		url = 'index.php?input&action=getCategoryProvider';

		$.doPostGetCategoryList(pid, '#selCatProvider2', url);				
	});	
</script>